﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SCCM_Client_Injector_2014
{
    public partial class MultiClientResultForm : Form
    {
        public MultiClientResultForm()
        {
            InitializeComponent();
            this.Text = Main.WindowTitle;
        }

        private void MultiClientResultForm_Load(object sender, EventArgs e)
        {
            foreach (string token in Main.ClientListResults)
            {
                string[] ResultRecord = token.Split(new string[] { "," }, StringSplitOptions.None);
                if (ResultRecord[0] != "")
                {
                    ListViewItem row = new ListViewItem(ResultRecord[0]);
                    row.SubItems.Add(new ListViewItem.ListViewSubItem(row, ResultRecord[2]));
                    if (ResultRecord[3] == "true")
                    {
                        row.SubItems.Add(new ListViewItem.ListViewSubItem(row, "Success"));
                        row.SubItems[2].ForeColor = Color.ForestGreen;
                    }
                    else 
                    {
                        row.SubItems.Add(new ListViewItem.ListViewSubItem(row, "Fail"));
                        row.SubItems[2].ForeColor = Color.DarkRed;
                    }
                    row.SubItems.Add(new ListViewItem.ListViewSubItem(row, ResultRecord[3]));
                    row.SubItems.Add(new ListViewItem.ListViewSubItem(row, ResultRecord[1]));
                    listViewResults.Items.Add(row);
                }
            }
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonCopyResults_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(Main.MultiClientList, TextDataFormat.Text);
        }
    }
}
